package design_pattern.proxy.staticProxy;

import design_pattern.proxy.enhanceService.EnhanceService;

/**
 * @author keyer
 * @Description : 静态代理对象，包含真实对象，和真实对象继承统一接口，为真实对象的服务提供增强
 * 代理类最大的意义，就是为代理接口的实现，做增强
 * Created by cyd on 2021-03-06 10:40:51
 */
public class ProductStaticRealProxy implements ProductSaleProxy {

    /**
     * 被包含的真实对象
     */
    private final ProductSaleProxy saleFactory;

    // 增强方法提供者对象
    private final EnhanceService enhanceProvider = new EnhanceService();

    public ProductStaticRealProxy(ProductSaleProxy factory) {
        super();
        this.saleFactory = factory;
    }

    /**
     * @param size 产品尺寸
     * @Description: 销售成人玩具
     * @DateTime: 2021/3/6 10:31
     * @Params: size 尺寸
     */
    @Override
    public void saleSomething(String size) {
        // 前置增强
        enhanceProvider.doSomethingBefore();
        saleFactory.saleSomething(size);
        // 后置增强
        enhanceProvider.doSomethingEnd();
    }

}
